Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: reconcile policy webhook configurations #576

Merged
merged 7 commits into from
Nov 21, 2023

Conversation

fabriziosestito
Copy link
Contributor

@fabriziosestito fabriziosestito commented Nov 14, 2023

Description

This PR fixes: #224, adding reconciliation of ValidatingWebhookConfiguration and MutatingWebhookConfiguration if those are changed (by the user).

Test

This PR introduces a k3s testcontainer to test the controllers against a real cluster, by using envtest.
The envtest setup was already there, but not using a real cluster we weren't able to test Kubernetes builtin resources "side-effects", e.g. creating a deployment was not causing a ReplicaSet and Pods to be created. This is because by default envtest spins up a fake control plane with no Kubernetes built-in controllers.
Also, we were lacking tests for the admission policies controllers' happy paths. This PR adds them.

NOTE: Webhooks integration tests are still not running against a real cluster, but using envtest in this case might be overkill.
Consider refactoring these tests to unit tests (see: #579)

go.mod Show resolved Hide resolved
@fabriziosestito fabriziosestito force-pushed the feat/webhooks-reconciliation branch 4 times, most recently from 64eefa4 to 0909b3f Compare November 17, 2023 13:23
controllers/admissionpolicy_controller.go Outdated Show resolved Hide resolved
controllers/clusteradmissionpolicy_controller.go Outdated Show resolved Hide resolved
controllers/suite_test.go Outdated Show resolved Hide resolved
controllers/suite_test.go Show resolved Hide resolved
controllers/utils_test.go Outdated Show resolved Hide resolved
@fabriziosestito fabriziosestito force-pushed the feat/webhooks-reconciliation branch 2 times, most recently from 0118d13 to 84be709 Compare November 18, 2023 08:42
@fabriziosestito fabriziosestito marked this pull request as ready for review November 18, 2023 10:35
@fabriziosestito fabriziosestito requested a review from a team as a code owner November 18, 2023 10:35
controllers/utils_test.go Outdated Show resolved Hide resolved
Copy link
Member

@viccuad viccuad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Good way of ensuring the webhooks stay as they should, plus the tests against a real cluster open a world of possibilities ❤️.

…oncile if changed

Signed-off-by: Fabrizio Sestito <fabrizio.sestito@suse.com>
…dmissionPolicy and ClusterAdmissionPolicy controllers

Signed-off-by: Fabrizio Sestito <fabrizio.sestito@suse.com>
…luster using a k3s testcontainer

Signed-off-by: Fabrizio Sestito <fabrizio.sestito@suse.com>
tests

Signed-off-by: Fabrizio Sestito <fabrizio.sestito@suse.com>
Signed-off-by: Fabrizio Sestito <fabrizio.sestito@suse.com>
Signed-off-by: Fabrizio Sestito <fabrizio.sestito@suse.com>
Signed-off-by: Fabrizio Sestito <fabrizio.sestito@suse.com>
Copy link
Member

@flavio flavio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, this is some great work 👏

Makefile Show resolved Hide resolved
@flavio flavio merged commit b48d736 into kubewarden:main Nov 21, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
4 participants